<?php
namespace app\admin\controller;
// use think\Db;
// use think\captcha\Captcha;
class Addshop extends Come{
    public function addshop(){
       
        return $this->fetch('addshop');
    }
    public function tianjia(){
        $data=input('param.','','htmlspecialchars');
        $title=input('param.title','','htmlspecialchars');
        $purchasePrice=input('param.purchasePrice','','htmlspecialchars');
        $marketPrice=input('param.marketPrice','','htmlspecialchars');
        $shopPrice=input('param.shopPrice','','htmlspecialchars');
        $salesNum=input('param.salesNum','','htmlspecialchars');
        $stockNum=input('param.stockNum','','htmlspecialchars');
        $classification=input('param.classification','','htmlspecialchars');
        $content=input('param.content','','htmlspecialchars');
        $data['img']=json_encode($data['img']); 
        $data['time']=time();

       
        $ret=db('admin_addshop')->insert($data);
            if($ret>0){
                $this->success('发布成功!','admin/addshop/addshop');
            }else{
                $this->error('发布失败');
            }
    }
    public function upload(){
        $file=request()->file('img');
            if($file){
                $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
                if($info){
                    $path=$info->getSaveName();
                    $img_src="/uploads/".$path;
                    echo $img_src;
                }else{
                    //	上传失败获取错误信息
                    $this->error($file->getError());
                }
            }
            else{
                $this->error("必须上传图片");
            }
    }
    public function index(){
        $id_num=input('param.fenlei','','htmlspecialchars');
        $ret=db('admin_shop')->where('num',$id_num)->select();
       
        return $ret;
        // return 12;
        
    }
}